﻿using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Dapper.SimpleDao.Infrastructure;
using System.Data;
using System.Net;
using System.Net.Http;

namespace Dapper.SimpleDao.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            IKernel kernal = new StandardKernel(new DevinjectModule());

           var s =  ApiHelper.Instance.GetUserToken();

            Console.WriteLine(s);

            #region 测试连接数

            //for (var i = 0; i <= 10000; i++)
            //{
            //    ParameterizedThreadStart threadStart = new ParameterizedThreadStart(Open);
            //    Thread thread = new Thread(threadStart);
            //    thread.Start(kernal);
            //    Console.WriteLine("线程：" + thread.ManagedThreadId);
            //}
            #endregion

            #region 测试方法

            //var team = kernal.Get<TeamRepository>();
            ////get方法
            //var b = team.Get("1");
            ////team实例
            //var t = new Team { org_id = 3, lower_name = "xx1", full_name = "xxx1" };
            //var t2 = new Team { org_id = 3, lower_name = "xx1", full_name = "xxx2" };

            ////委托方法集合
            //List<FuncParamater<Team>> list = new List<FuncParamater<Team>>();
            //list.Add(new FuncParamater<Team>() { func = team.Insert, obj = t });

            //var i = (team.Insert(t2) > 0 ? true : false) || team.Commit(list);
            //Console.WriteLine(b.org_id + ":" + i.ToString());

            #endregion


            Console.ReadLine();
        }

        public static void Open(object kernal)
        {
            IKernel k = (IKernel)kernal;
            var context = k.Get<MySqlDbContext>();
            using (var connection = context.Connection)
            {
                Console.WriteLine("connection" + connection.State);
            }
        }
    }
}
